package com.evil.kingdom.service.core.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.evil.kingdom.pojo.dto.core.MountDto;
import com.evil.kingdom.pojo.entity.core.Mount;
import com.evil.common.mongo.service.impl.SingleServiceImpl;
import com.evil.kingdom.repository.core.MountRepository;
import com.evil.kingdom.service.core.MountService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 坐骑
 *
 * @author liyang
 * @date 2024-05-22 17:48
 */
@Slf4j
@Service
@AllArgsConstructor
public class MountServiceImpl extends SingleServiceImpl<MountRepository, Mount> implements MountService {

    @Override
    public MountDto findDtoByName(String name) {
        return BeanUtil.copyProperties(this.findByName(name), MountDto.class);
    }

    @Override
    public List<MountDto> findDtoByNames(Collection<String> name) {
        if (CollectionUtil.isEmpty(name)) {
            return new ArrayList<>();
        }
        return BeanUtil.copyToList(this.findByNames(name), MountDto.class);
    }
}
